/* * Copyright 2009 the original author or authors. *  * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * *     http://www.apache.org/licenses/LICENSE-2.0 *      * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */import javax.servlet.ServletResponseimport javax.servlet.ServletResponseWrapperimport org.grails.jaxrs.web.JaxrsContextimport org.grails.jaxrs.web.RequestWrapper
import org.restlet.Applicationimport org.restlet.Context
/** * Dispatches HTTP requests to one of the JAX-RS implementations supported by * the plugin. *  * @author Martin Krasser */class JaxrsController {
		static def defaultAction = 'handle'	    def jaxrsContext         
    def handle = {        jaxrsContext.jaxrsService.process(new RequestWrapper(request), response)        // Flush the output stream on the unwrapped response to enforce        // response.committed set to true. This doesn't work with the        // original servlet response object (which violates the servlet        // spec). This is needed to prevent grails from special-handling        // html-related content types.        // See also http://jira.codehaus.org/browse/GRAILS-1223        unwrappedResponse.outputStream.flush()        return null    }
    private ServletResponse getUnwrappedResponse() {        def unwrapped = response        while (unwrapped instanceof ServletResponseWrapper) {            unwrapped = unwrapped.response        }        return unwrapped            } }
